﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace MODULE_DANHMUC
{
    public class cls_danhmuc
    {


        public  System.Windows.Forms.Form parent;
        public static danhmucDataContext getcontext()
        {
            danhmucDataContext context = new danhmucDataContext(getconnectstring());
            return context;
        }
        
        public void ShowForm(string formname)
        {
            
            switch (formname)
            {
                case "frm_danhmucnhanvien":
                    frm_danhmucnhanvien frmnv = new frm_danhmucnhanvien();
                    frmnv.Show();
                    frmnv.MdiParent = parent;
                    break;
                case "frm_danhmuchanghoa":
                    frm_danhmuchanghoa frmhh = new frm_danhmuchanghoa();
                    frmhh.Show();
                    frmhh.MdiParent = parent;
                    break;
                case "frm_danhmucchuhang":
                    frm_danhmucchuhang frmch = new frm_danhmucchuhang();
                    frmch.Show();
                    frmch.MdiParent = parent;
                    break;
                case "frm_danhmucnguoisudung":
                    frm_danhmucnguoisudung frmnsd = new frm_danhmucnguoisudung();
                    frmnsd.Show();
                    frmnsd.MdiParent = parent;
                    break;
            }
        }
        public static string getconnectstring()
        {
            string kq = "";
            XmlDocument MyDoc = new XmlDocument();

            MyDoc.Load("extension\\extension.xml");
            XmlNode root = (XmlNode)MyDoc.DocumentElement;

            for (int i = 0; i < root.ChildNodes.Count; i++)
            {
                XmlNode element = (XmlNode)root.ChildNodes[i];
                if (element.Name == "connection")
                {
                    kq = element.Attributes["connectionString"].Value.ToString();
                }
            }
            return kq;

        }


    }
}
